#!/usr/bin/python

# Author: Sergey Vartanov (me@enzet.ru)

import sys

first = open(sys.argv[1], 'r')

spec = ["#PC", "THR_START", "THR_FIRST_INSN", "THR_END", "THR_JOIN_AFTER", "RTN_CALL", "SBLOCK_ENTER", "RTN_EXIT", "READ", "WRITE", "WRITER_LOCK", "UNLOCK", "WAIT", "SIGNAL"]

line = first.readline()
while line != "":
  words = line.split(" ")

  correct = False

  for s in spec:
    if words[0] == s:
      correct = True

  if len(words) > 6 or len(words) < 5:
    print("Trace is not correct.")
    break
    
  if not correct:
    print("Trace is not correct: first word of line is " + words[0])
    break
    
  line = first.readline()
